package com.leet.code.simple_array;

/**
 * @description:    1351.统计有序矩阵中的负数
 * @author: WYG
 * @time: 2021/1/2 10:06
 */

public class CountNegatives {
    public int countNegatives(int[][] grid) {
        int res = 0;
        for (int i = 0; i < grid.length; i++) {
            for (int j = 0; j < grid[0].length; j++) {
                if (grid[i][j] < 0) {
                    res += grid[0].length - j;
                    break;
                }
            }
        }
        return res;
    }
}
